/*
 * LexicalTree.java
 *
 * Created on July 4, 2006, 1:07 PM
 *
 */

package galronnlp.util;

import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author Daniel A. Galron
 */
public class LexicalTree extends Tree {
    private boolean displayProbs = true;
    private TreeStringGenerator stringGen = new PennTreebankStringTreeGenerator(displayProbs);
        
    /** Creates a new instance of LexicalTree */
    public LexicalTree(Symbol cat, Symbol w, double prob) {
        type = LEXICAL;
        //System.err.println(this.children);
        this.children.addLast(w);
        this.probability = prob;
        this.category = cat;
    }
    
    public LexicalTree(Symbol cat, Symbol w) {
        this(cat, w, 0.0);
    }
    
    public LinkedList<Symbol> RHS() {
        LinkedList<Symbol> RHS = new LinkedList<Symbol>();
        for(Iterator<Symbol> it = this.children.iterator(); it.hasNext(); ) {
            RHS.addLast(it.next());
        }
        return RHS;
    }
    
    public boolean equals(Object o) {
        Tree other = (Tree)o;
        boolean ret = false;
        if(other.type() == LEXICAL) {
            ret = ((Symbol)this.children.get(0)).equals((Symbol)other.children.get(0)) &&
                    this.category.equals(other.category);
        }
        return ret;
    }
}
